<?php
/**
 * Created by PhpStorm.
 * User: idcu
 * Date: 2016/3/9
 * Time: 19:30
 */
namespace Admin\Controller;
use IDCU\Controller;

class CrmUserController extends Controller
{
    public function oa(){
        $this->display();
    }

    public function oaUser(){
        $this->display();
    }

    public function getRoles(){
        $this->ajaxReturn(M('Role')->select());
    }

    public function search(){
        $param = $this->getParam();
        $modelName = $this->modelName;
        $scope = array();
        $relation = array();
        $search = $this->getSearch();
        $page = $this->getPage();
        $data = D($modelName)->where($param)->where($search)->scope($scope)->relation($relation)->page($page[0],$page[1])->select();
        if($data){
            $res['stat'] = 1;
            $res['data'] = $data;
            $res['count'] = $data = D($modelName)->where($param)->where($search)->scope($scope)->count();
            $res['msg'] = '查找到1条数据。';
        }elseif($data == null){
            $res['stat'] = 1;
            $res['data'] = array();
            $res['count'] = 0;
            $res['msg'] = '查找到0条数据。';
        }else{
            $res['stat'] = 0;
            $res['data'] = $data;
            $res['msg'] = '查找失败！';
        }
        $res[''] = $res['count'];
        $res[''] = $res['count'];
        $this->ajaxReturn($res);
    }
}